package com.af.task;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author : zhenyun.su
 * @comment : 自定义认为
 *  String key; 唯一标识
 *  String type;  任务类型，用于区分不同业务类型， 可为空
 *  T value;     任务内容
 *  String extValue;  任务内容或扩展内容
 *  LocalDateTime createdTime;  任务创建时间
 * @since : 2022-9-3
 */

public class AfTask<T> implements Serializable {
    private String key;
    private String type;
    private T value;
    private String extValue;
    private LocalDateTime createdTime;

    public static <T> AfTask of(String key, T value, String type, String extValue){
        AfTask task = new AfTask();
        task.setKey(key);
        task.setValue(value);
        task.setType(type);
        task.setExtValue(extValue);
        task.setCreatedTime(LocalDateTime.now());
        return task;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public T getValue() {
        return value;
    }

    public void setValue(T value) {
        this.value = value;
    }

    public String getExtValue() {
        return extValue;
    }

    public void setExtValue(String extValue) {
        this.extValue = extValue;
    }

    public LocalDateTime getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(LocalDateTime createdTime) {
        this.createdTime = createdTime;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Override
    public String toString() {
        return "SzyTask{" +
                "key='" + key + '\'' +
                ", type='" + type + '\'' +
                ", value=" + value +
                ", extValue='" + extValue + '\'' +
                ", createdTime=" + createdTime +
                '}';
    }
}
